import logging
import redis


class Config(object):
    # 秘钥配置
    SECRET_KEY = "LSKDJLXBLU213"

    DEBUG = True

    # MySql数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@localhost:3306/information14"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = "6379"

    # flask_session配置
    SESSION_TYPE = "redis"  # 指定session保存到redis
    SESSION_USE_SINGER = True
    SESSION_REDIS = redis.StrictRedis(REDIS_HOST, REDIS_PORT)
    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 3600 * 24 * 2

#  设置默认日志级别
    LEVEL = logging.DEBUG

# 开发环境配置信息
class DevelopConfig(Config):
    pass

# 生产环境配置信息(线上)
class ProductConfig(Config):
    DEBUG = False
    LEVEL = logging.ERROR


# 测试环境配置信息
class TestingConfig(Config):
    TESTING = True

# 通过字典统一访问配置类
config_dict = {
    'develop':DevelopConfig,
    'product':ProductConfig,
    'testing':TestingConfig
}